/**
 * ------------------------------------------------------------------------------------------
 * Copyright (c): Company, 2012 This software is the
 * proprietary information of FHWS, Würzburg All Right Reserved.
 * ------------------------------------------------------------------------------------------
 *
 *
 * @project: Vorlesungplan
 * @copyright FHWS 2012
 * @link       http://mussnocheingeragenwerden.de
 * @package    tt.model
 *
 * SVN revision information:
 *
 * @version $Rev$:
 * @author $Author$:
 * @date $Date$:
 */

package tt.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

@Entity
@Table(name = "lecturer")
@XmlRootElement
@NamedQueries(
{
   @NamedQuery(name = "Lecturer.findAll", query = "SELECT l FROM Lecturer l"),
   @NamedQuery(name = "Lecturer.findByIdlecturer", query = "SELECT l FROM Lecturer l WHERE l.idlecturer = :idlecturer"),
   @NamedQuery(name = "Lecturer.findByName", query = "SELECT l FROM Lecturer l WHERE l.name = :name"),
   @NamedQuery(name = "Lecturer.findByFirstname", query = "SELECT l FROM Lecturer l WHERE l.firstname = :firstname"),
   @NamedQuery(name = "Lecturer.findByTitel", query = "SELECT l FROM Lecturer l WHERE l.titel = :titel")
})
public class Lecturer implements Serializable
{

   private static final long serialVersionUID = 1L;
   @Id
   @GeneratedValue(strategy = GenerationType.IDENTITY)
   @Basic(optional = false)
   @Column(name = "idlecturer")
   private Integer idlecturer;
   @Basic(optional = false)
   @NotNull
   @Size(min = 1, max = 45)
   @Column(name = "name")
   private String name;
   @Size(max = 45)
   @Column(name = "firstname")
   private String firstname;
   @Size(max = 45)
   @Column(name = "titel")
   private String titel;
   @ManyToMany(mappedBy = "lecturerCollection")
   private Collection<Lecturedate> lecturedateCollection;
   @OneToMany(mappedBy = "secondexaminer")
   private Collection<Exam> examCollection;
   @OneToMany(mappedBy = "firstexaminer")
   private Collection<Exam> examCollection1;

   public Lecturer()
   {
   }

   public Lecturer(Integer idlecturer)
   {
      this.idlecturer = idlecturer;
   }

   public Lecturer(Integer idlecturer, String name)
   {
      this.idlecturer = idlecturer;
      this.name = name;
   }

   public Integer getIdlecturer()
   {
      return idlecturer;
   }

   public void setIdlecturer(Integer idlecturer)
   {
      this.idlecturer = idlecturer;
   }

   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }

   public String getFirstname()
   {
      return firstname;
   }

   public void setFirstname(String firstname)
   {
      this.firstname = firstname;
   }

   public String getTitel()
   {
      return titel;
   }

   public void setTitel(String titel)
   {
      this.titel = titel;
   }

   @XmlTransient
   public Collection<Lecturedate> getLecturedateCollection()
   {
      return lecturedateCollection;
   }

   public void setLecturedateCollection(Collection<Lecturedate> lecturedateCollection)
   {
      this.lecturedateCollection = lecturedateCollection;
   }

   @XmlTransient
   public Collection<Exam> getExamCollection()
   {
      return examCollection;
   }

   public void setExamCollection(Collection<Exam> examCollection)
   {
      this.examCollection = examCollection;
   }

   @XmlTransient
   public Collection<Exam> getExamCollection1()
   {
      return examCollection1;
   }

   public void setExamCollection1(Collection<Exam> examCollection1)
   {
      this.examCollection1 = examCollection1;
   }

   @Override
   public int hashCode()
   {
      int hash = 0;
      hash += (idlecturer != null ? idlecturer.hashCode() : 0);
      return hash;
   }

   @Override
   public boolean equals(Object object)
   {
      // TODO: Warning - this method won't work in the case the id fields are not set
      if (!(object instanceof Lecturer))
      {
         return false;
      }
      Lecturer other = (Lecturer) object;
      if ((this.idlecturer == null && other.idlecturer != null) || (this.idlecturer != null && !this.idlecturer.equals(other.idlecturer)))
      {
         return false;
      }
      return true;
   }

   @Override
   public String toString()
   {
      return "tt.model.Lecturer[ idlecturer=" + idlecturer + " ]";
   }

   public String getWholeName()
   {
      if (titel == null)
      {
         titel = "";
      }
      if (firstname == null)
      {
         firstname = "";
      }
      if (name == null)
      {
         name = "";
      }
      return titel + " " + firstname + " " + name;
   }//endmethod
}
